package com.myt.matp.gui;

import com.myt.matp.core.FontSystem;
import com.myt.matp.utils.Edit;

import javax.microedition.lcdui.*;

public final class MGraphics {

    FontSystem m_FontSystem = null;
    Graphics m_Graphics = null;

    protected MGraphics(FontSystem fsys) {
	m_FontSystem = fsys;
    }

    public void setGraphics(Graphics g) {
	m_Graphics = g;
    }

    public Graphics getGraphics() {
	return m_Graphics;
    }

    /*
     * Fonts
     *
     */
    public void setFont(int face, int style, int size) {
	m_FontSystem.setFont(face, style, size);
    }

    public int getFontHeight() {
	return m_FontSystem.getFontHeight();
    }

    public int getCharWidth(char c) {
	return m_FontSystem.charWidth(c);
    }

    public int getCharsWidth(Edit editor, int start, int length) {
	return m_FontSystem.charsWidth(editor, start, length);
    }

    /*
     * Painting
     *
     */

    public void drawChar(Graphics g, char character, int x, int y, int anchor) {
	m_FontSystem.drawChar(g, character, x, y, anchor);
    }

    public void drawChar(char character, int x, int y, int anchor) {
	drawChar(m_Graphics, character, x, y, anchor);
    }

    public void drawLine(int x1, int y1, int x2, int y2) {
	m_Graphics.drawLine(x1, y1, x2, y2);
    }

    public void drawRect(int x, int y, int width, int height) {
	m_Graphics.drawRect(x, y, width, height);
    }

    public void setColor(int RGB) {
	m_Graphics.setColor(RGB);
    }

    public void fillRect(int x, int y, int width, int height) {
	m_Graphics.fillRect(x, y, width, height);
    }

    public void setStrokeStyle(int style) {
	m_Graphics.setStrokeStyle(style);
    }

    public void drawImage(Image img, int x, int y, int anchor) {
	m_Graphics.drawImage(img, x, y, anchor);
    }

    public void setClip(int x, int y, int width, int height) {
	m_Graphics.setClip(x, y, width, height);
    }

    public void translate(int x, int y) {
	m_Graphics.translate(x, y);
    }
}